package com.hjl.controller;

import com.hjl.pojo.Admin;
import com.hjl.pojo.Emp;
import com.yqs.model.service.AdminService;
import com.yqs.model.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


/**
 * @author ServivE
 * @version 0.1
 * @className AdminController
 * @description
 * @date 2024/8/20 15:54
 * @since jdk17
 */
@Controller
@RequestMapping("admin")
public class AdminController {
    @Autowired
    private AdminService adminService;
    @Autowired
    private EmpService empService;
    @RequestMapping("tologin")
    public String tologin() {
        return "login";
    }

    @RequestMapping("find")
    public String findAdmin(Admin admin,Model model) {
        Admin admin1 = adminService.selectAnameAndApwd(admin);
        if (admin1 != null && admin.getApwd().equals(admin1.getApwd())) {
            model.addAttribute("aname", admin1.getAname());

            List<Emp> list = empService.queryAll();
            model.addAttribute("list", list);

            return "loginSuccessful";
        }
        return "login";
    }
}
